/**
 * @Description:
 * @author 紫霞
 * @since 2019/1/17
 */
// React基础组件
import React from 'react'
// dva 连接组件 - 连接route和model
import { connect } from 'dva'
// 引入antd的组件
import { Form, Select, Input, DatePicker, Button } from 'antd'
import moment from 'moment';
const { RangePicker } = DatePicker;
const dateFormat = 'YYYY/MM/DD';
//导入路由组件，用于跳转等
import { Link, hashHistory } from 'dva/router'
// 导入项目全局配置文件
import config from 'config/config'

// 引入model取值工具方法
import { mapStateToProps } from 'utils/view_utils'
// 当前组件样式
import styles from './recommendClientsListStyle.less'
//引用listPage
import ListPage from 'widget/PageTmpl/ListPage'
import cx from 'classnames'

const Option = Select.Option;
/**
 * description 路由视图及事件处理
 * dispatch 分发到models中的effects对应事件名
 * model 用于获取models中state定义的数据
 * form 表单对象
 */

const infoListAdminView = function ({ dispatch, model, form }) {
  // 表单的子函数
  const { resetFields, getFieldDecorator, validateFields, setFieldsValue } = form;
  const { modelObj, namespace } = model
  const {referrerName,referrerMobile,data} = modelObj;
  // 取出model对象，命名空间
  // const { modelObj, namespace } = model
  // modelObj.xxx获取model中状态机的值

  let pageProps = {
    // ---------- 界面部分 ----------
    "ui": {
      // 页面接口地址
      // "api_url": "admin/appointmentHouse/queryAppointmentHouseCount",
      "api_url": "admin/user/queryReferCustomerList",
      // 接口方式
      "method": "POST",
      "app": "",
      // 接口参数
       "params": "referrerName=" + referrerName + "&referrerMobile=" + referrerMobile + "&pageNo=1&pageSize=10",
      // 模拟数据 - 用于开发需要，若填充了上面的api_url之后，请将此项设置为null
      // "mockData": mockData,
      "mockData": null,
      "refreshByEnter": true,
      
      // 数据表格
      "table":
      {
        "status_params": "status=0",
        "status_text": "全部",
        // 表头字段列表
        "scroll": { x: 1000 },
        "fields": [
          {
            "en_name": "name",
            "zh_name": "姓名",
          },
          {
            "en_name": "mobile",
            "zh_name": "手机号",
            width:130,
          },
          {
            "en_name": "productName",
            "zh_name": "楼盘",
          },
          {
            "en_name": "appointmentTime",
            "zh_name": "预约时间",
          }
        ]
      },
    },
  }
  
  if (!!modelObj.biz) {
    pageProps.biz = modelObj.biz
    pageProps.biz.syncBackCbf = (biz) => {
      dispatch({
        type: `${namespace}/setFormVal`,
        payload: biz
      })
    }
  }
  return (
    <div className={cx('pageLayout')}>
      <div className={styles.referrerBox}>
        <span>推荐人: {referrerName}</span>
        <span>推荐人电话:{referrerMobile}</span>
      </div>
      <ListPage pageProps={pageProps}/>
    </div>
  )
}

// 连接视图(view)和模型(model)
export default connect(mapStateToProps)(Form.create()(infoListAdminView))
